/*
 * scheduler.h
 *
 *  Created on: Mar 4, 2012
 *
 *
 *	@input
 *	process * *[]
 *  The scheduler will be called each time the CPU receives an interrupt or a process makes a system call.
 *
 *  implements round-robin, priority, and lottery scheduling policies (described in section 2.4.3 of the
 *	textbook).
 *
 *	round-robin
 *	The scheduler will select the next process from the runnable processes based on location in the rotation
 *
 *	Priority
 *	The scheduler will select the next process from the runnable processes based on Priority of process.
 *	Ties decided with rock paper scissors
 *
 *	Lottery
 *	The scheduler will select the next process from the runnable processes based on location in the rotation
 *
 *	the Scheduler has a simple API; it will:
 *	* Gets the next runnable process
 *	* Blocks a process that's currently running and removes it from the runnable process rotation
 *	* Unblocks a proccess that was blocked, and adds it to the runnable process rotation
 *
 */

#ifndef SCHEDULER_H_
#define SCHEDULER_H_
#include "../Processes/process.h"
#include "../Utility/queue.h"

//#define int PRIORITY_ORDER[4] = {0,1,2,3};

typedef struct {
	int operating_mode;		//0: round-robin
							//1: for priority
							//2: Lottery

	int total_process_count;

	process * my_running_process;

	Queue my_process_queue;

	/* for priority scheduling */
	/* lower priorities are favored */
	Queue priority_0_queue;
	Queue priority_1_queue;
	Queue priority_2_queue;
	Queue priority_3_queue;

	Queue priority_queue_array[4];

	int PRIORITY_ORDER[4];

	Queue memory_blocked_processes;

	process **  my_process_array;

	process * (*get_next_process)(void *);

} scheduler;

/*
 * 0 for round-robin
 */
scheduler * scheduler_init(int operating_mode, process ** processes, int num_processes);

int unblock_process(scheduler * self, int process_id);
int unblock_memory(scheduler * self, int memory_location);

int block_running_process(scheduler * self,int process_id);
//int block_mem_process(scheduler * self,int process_id);

void printOutput(scheduler * self);
//process * getNextProcess(scheduler *);
//process * get_next_priority_process(scheduler * self);

#endif /* SCHEDULER_H_ */
